home *** CD-ROM | disk | FTP | other *** search
- Path: ida.his.se!a95hanne
- From: a95hanne@ida.his.se (Hannu Nevalainen)
- Newsgroups: comp.lang.c,alt.msdos.programmer
- Subject: Re: Two strange C problems.
- Followup-To: comp.lang.c,alt.msdos.programmer
- Date: 8 Jan 1996 23:15:40 GMT
- Organization: University of Skoevde
- Distribution: world
- Message-ID: <4cs8is$p4s@mhost.ida.his.se>
- References: <4cojb2$qog@lugb.latrobe.edu.au>
- NNTP-Posting-Host: oden.ida.his.se
- X-Newsreader: TIN [version 1.2 PL2]
-
- Gregary John Boyles (cs102238@lux.latrobe.edu.au) wrote:
- : I have two C problems.
-
- : PROBLEM 1 :
-
- <snip, snip>
-
- : PROBLEM 2 :
-
- : const escape=27;
- : const cr=13;
- : const bs=8;
-
- : while (ch!=cr)
- : {
- : .
- : .
- : .
- : }
-
- : while (ch!=escape)
- : {
- : .
- : .
- : .
- : }
-
- : If I replace the 27 with \27' or the 13 with '\13' then these loops don't
- : work i.e. an infinite loop results. WHY?
-
- You will most probably get the numbers 'interpreted' as OCTAL values.
- That's the default, if I'm not too wrong. At least it is if one types
- \033 which would be decimal 27 (ESC). I one types \x1b then one would be
- using hexadecimal (the example equals ESC again).
-
- : Also if I want to do somthing like this : puts("\24 \25"); which should
- : print the up and down arrows on the screen (ASCII 24 and 25), but no, it
- : prints some other ASCII characters. As far as I can tell C has its own
- : unique character table, at least for the control characters. WHY?
-
- : Sometimes I wonder whether some one needs to go back an rewrite the damn
- : language so that it works sensibly and predictably like Pascal can be
- : relied upon to do.
-
-
- In my opinion; sorry but - you have some reading to do.
-
- "The C Programming Language" by B W Kernighan/D M Ritchie is a good
- reference book. While there are some teaching attempts there are better
- books of that kind. (ISBN 0-13-110362-8, second ed.)
-
- Pascal puts up a lot of hindrance that simply isn't there in C.
- (My opinion again ;-)
-
- /Hannu
- -- _ __
- _ // Simplicity is the point, | | | | | | /
- \\ // Amiga versatiliy helps. |-| |- |\| |/
- \X/"mainiac" a95hanne@ida.his.se | |.|__.| |.| \.
-
- Running an Amiga; '030 @50Mhz, '882 @50MHz, 10M RAM & 400M HD
-
- "Life starts at '030, fun starts at '040, impotence starts at '86."
-